<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<title>梵創洗車</title>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0,user-scalable= no"/>

<link href="__PRIVATE__/css/style.css" rel="stylesheet">
<link href="__PRIVATE__/css/upload_img.css" rel="stylesheet">
<script type="text/javascript" src="__PRIVATE__/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="__PRIVATE__/js/jquery.SuperSlide.2.1.1.js"></script>
<script type="text/javascript" src="__PRIVATE__/js/dropdown.js"></script>
<script type="text/javascript" src="__PRIVATE__/js/jquery.cookie.js"></script>
<script type="text/javascript" src="__PRIVATE__/js/jquery.form.js"></script>
<!--head start-->
</head>
<body>

<div class="header">
	<div class="left fl"></div>
	<div class="title fl">梵創洗車</div>
	<div class="right fr"><div>地圖</div></div>
	<div class="cl"></div>
</div>
<script type="text/javascript">
$('.header .right div').click(function(){
	window.location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/map')}";
});
</script>
<script src="__PRIVATE__/js/layer/layer.js"></script>
<form enctype="multipart/form-data" id="upForm" method="post">
<div class="box2">
	<input id="sercver_id" style="display:none;" value="2">
	<div class="remarks">
		備註：<br/>
		<if condition="$info.start_time neq null">
		<br/>
		{$info.car_remark}
		<elseif condition="$info.start_time eq null"/>
		<input type="text" class="car_remarks" name="car_remarks" placeholder="請描述車輛情況"/>
		</if>
	</div>

	<div class="upload_img fl">車頭<br/>
	<if condition="$info.start_time neq null">
		<img id="carhead" src="/upload/{$info.carhead_img}"/>
	<elseif condition="$info.start_time eq null"/><!-- accept="image/*" capture="camera" 直接調起攝像頭 -->
		<img id="carhead" src="__PRIVATE__/images/add_img.png"/><input type='file' capture="camera" id="upload_carhead"  name='photo[]' onchange="showPicture(this)" style="display:none;">
	</if>
	</div>
	<div class="upload_img fl">左側<br/>
	<if condition="$info.start_time neq null">
		<img id="carleft" src="/upload/{$info.carleft_img}"/>
	<elseif condition="$info.start_time eq null"/>
		<img id="carleft" src="__PRIVATE__/images/add_img.png"/><input type='file' capture="camera" id="upload_carleft"  name='photo[]' onchange="showPicture2(this)" style="display:none;">
	</if>
	</div>
	<div class="upload_img fl">右側<br/>
	<if condition="$info.start_time neq null">
		<img id="carright" src="/upload/{$info.carright_img}"/>
	<elseif condition="$info.start_time eq null"/>
		<img id="carright" src="__PRIVATE__/images/add_img.png"/><input type='file' capture="camera" id="upload_carright"  name='photo[]' onchange="showPicture3(this)" style="display:none;">
	</if>
	</div>
	<div class="upload_img fl">車尾<br/>
	<if condition="$info.start_time neq null">
		<img id="carback" src="/upload/{$info.carback_img}"/>
	<elseif condition="$info.start_time eq null"/>
		<img id="carback" src="__PRIVATE__/images/add_img.png"/><input type='file' capture="camera" id="upload_carback"  name='photo[]' onchange="showPicture4(this)" style="display:none;">
	</if>
	
	</div>
	<div class="cl"></div>
	
<script type="text/javascript">
$('.upload_img img').click(function(){
	$(this).siblings('input[type=file]').click();
});
function showPicture(imgFile){
	var picURL = window.URL.createObjectURL(imgFile.files[0]);
	document.getElementById("carhead").src = picURL;
	$('#upload_carhead').val(picURL);
} 
function showPicture2(imgFile){
	var picURL = window.URL.createObjectURL(imgFile.files[0]);
	document.getElementById("carleft").src = picURL;
	$('#upload_carleft').val(picURL);
} 
function showPicture3(imgFile){
	var picURL = window.URL.createObjectURL(imgFile.files[0]);
	document.getElementById("carright").src = picURL;
	$('#upload_carright').val(picURL);
} 
function showPicture4(imgFile){
	var picURL = window.URL.createObjectURL(imgFile.files[0]);
	document.getElementById("carback").src = picURL;
	$('#upload_carback').val(picURL);
} 
function showPicture5(imgFile){
	document.getElementById("orther").src = window.URL.createObjectURL(imgFile.files[0]);
} 
</script>
	<if condition="$info.start_time neq null">
	<div class="end_wash">結束任務</div>
	<elseif condition='$info.start_time eq null'/>
	<div class="upload_wash_info add_washer">開始洗車</div>
	</if>
</div>
<input type="hidden" id="ordersn" name="ordersn" value="{$_GET['ordersn']}"/>
<input type="hidden" id="orderId" name="orderId" value="{$info.id}"/>
</form>
<script type="text/javascript"> 
$('.washer').click(function(){
	if($(this).attr('num')==0){
		$(this).children('.img').children('img').attr('src','__PRIVATE__/Images/checked.png');
		$(this).attr('num','1');
	}else{
		$(this).children('.img').children('img').attr('src','__PRIVATE__/Images/no_checked.png');
		$(this).attr('num','0');
	}
});
$('.confirm').click(function(){
	var id_list='';
	var name_list = '';
	$('#s_id').val("");
	$('.washer').each(function(){
		if($(this).attr('num')==1){
			id_list = $(this).attr('server_id') + ',' + id_list;
			name_list = name_list + ',' + $(this).children('.washer_name').html();
		}
	});
	$('#s_id').val(id_list);
	name_list = name_list.substring(1);
	$('.show_washer').html('您選擇了 '+name_list);
	$('.add_washer').hide();
	
	$('.upload_wash_info').show();
	closeBg();
});

$('.upload_wash_info').click(function(){
	if($('.car_remarks').val()==''){
		layer.open({
				style:'font-size:1.6rem;',
				content:'請輸入備註',
				time:2,
		});
		return false;
	}
	
	var checkfile = 0;
	$('input[type=file]').each(function(){
		if($(this).val()==''){
			checkfile = checkfile + 1;
		}
	});
	if(checkfile != 0){
		layer.open({
			style:'font-size:1.6rem;',
			content:'請上傳車輛圖片',
			time:2,
		});
		return false;
	}
	layer.open({
		style:'font-size:1.6rem;',
		content:'正在上傳請稍後',
	});
	 var formData = new FormData($( "#upForm" )[0]);   
     $.ajax({    
          url: "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/upload_wash_info')}" ,  /*这是处理文件上传的servlet*/  
          type: 'POST',    
          data : formData,    
          async: false,    
          cache: false,    
          contentType: false,    
          processData: false,    
          success: function (returndata) {    
        	  layer.open({
  				style:'font-size:1.6rem;',
  				content:returndata.info,
  				time:2,
  				end:function(){
					window.location.href = returndata.url;
		 		}
  			});
          },    
          error: function (XMLHttpRequest, textStatus, errorThrown) {    
        	  alert(XMLHttpRequest.status);
        	  alert(XMLHttpRequest.readyState);
        	  alert(textStatus);
          }    
     });    
});

$('.end_wash').click(function(){
	var formData = new FormData($( "#upForm" )[0]);   
    $.ajax({    
         url: "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/end_wash')}" ,  /*这是处理文件上传的servlet*/  
         type: 'POST',    
         data : formData,    
         async: false,    
         cache: false,    
         contentType: false,    
         processData: false,    
         success: function (returndata) {   
        	 if(returndata.status==1){
        		 layer.open({
        				style:'font-size:1.6rem;',
        				content:returndata.info,
        				time:2,
        				end:function(){
        					window.location.href = returndata.url;
        		 		}
        		 });
        	 }else{
        		 layer.open({
     				style:'font-size:1.6rem;color:#FF0000',
     				content:returndata.info,
     				time:2,
     			});
        	 }
         },    
         error: function (returndata) {    
         },
    });  
});
</script>
<script type="text/javascript">
$('.add_washer').click(function(){
	$('#div').show();
});
</script>

<script type="text/javascript">
$('title').html('洗車前的拍照記錄');
$('.header .title').html('洗車前的拍照記錄');
$('.header .title').css('font-size','1.5rem');
$('.header .left').html('<img src="__PRIVATE__/images/left.png" style="width:55%"/>');
$('.header .right').html('');
$('.header .left').click(function(){
	<if condition="$user.p_id eq 0">
	window.location.href = "{:U(MODULE_NAME.'/server/server_order_list')}"; 
	<elseif condition="$user.p_id neq 0"/>
	window.location.href = "{:U(MODULE_NAME.'/server/washer_order_list')}"; 
	</if>
});
</script>
